package practice_3_2;

import java.util.Random;
import java.util.Scanner;

// 完成猜数字游戏，用户输入数字，判断该数字是大于，小于，
// 还是等于随机生成的数字，等于的时候退出程序.
public class GuessGame {
    public static void main(String[] args) {
        Random random = new Random();
        //获取一个[1， 100]的数作为要猜测的数
        int geussNum = random.nextInt(100) + 1;
        Scanner scanner = new Scanner(System.in);
        int answerNum = 0;
        while(true){
            System.out.println("输入[1, 100]的答案：");
            answerNum = scanner.nextInt();
            if(geussNum > answerNum){
                System.out.println("小了");
            }else if(geussNum < answerNum){
                System.out.println("大了");
            }else {
                System.out.println("恭喜你，猜对了！");
                break;
            }
        }
    }
}
